package org.infodavid.common.scheduler;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.infodavid.common.lang.ClassUtil;
import org.infodavid.common.scheduler.impl.PersistenceHelperImpl;

/**
 * The Class PersistenceHelper.
 */
public abstract class PersistenceHelper {

	/** The Constant log. */
	private static final Log LOGGER = LogFactory.getLog(PersistenceHelper.class);

	/** The singleton. */
	private static final PersistenceHelper SINGLETON;

	static {
		try {
			SINGLETON = ClassUtil.getInstance().newInstance(PersistenceHelperImpl.class);
		}
		catch (final Throwable e) {
			LOGGER.error("An error occurs while instantiating singleton", e);

			throw new Error(e);
		}
	}

	/**
	 * returns the singleton.
	 * @return <code>PersistenceHelper</code>
	 */
	public static PersistenceHelper getInstance() {
		return SINGLETON;
	}

	/**
	 * Instantiates a new helper.
	 */
	protected PersistenceHelper() {
		super();
	}

	public abstract void initializeDataSource(final String jndiName) throws Exception;
}
